const Sequelize = require('sequelize');
const DB = require("../config/dbconfig");

const imgModel = DB.define('img_tab', {
    img_id: {
      type: Sequelize.INTEGER,
      allowNull: false,
      primaryKey: true,
      comment: "图片表id，主键，此表只保存用户图片，不保存动态图片"
    },
    url: {
      type: Sequelize.STRING(50000),
      allowNull: true,
      comment: "图片内容"
    },
    user_id: {
      type: Sequelize.INTEGER,
      allowNull: true,
      comment: "用户表外键",
      references: {
        model: 'user_tab',
        key: 'user_id'
      }
    },
    create_time:{
      type:Sequelize.DATE,
      allowNull:true,
      comment:"上传时间"
    },
    is_delete:{
      type:Sequelize.INTEGER(2),
      comment:"是否删除"
    },
    description:{
      type:Sequelize.STRING(255),
      comment:"描述"
    }
  }, {
    Sequelize,
    tableName: 'img_tab',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "img_id" },
        ]
      },
      {
        name: "img_user",
        using: "BTREE",
        fields: [
          { name: "user_id" },
        ]
      },
    ]
  });
module.exports = imgModel
